/**
 * @author banglong
 * @date 2016/9/22.
 */
define([''], function () {

  function BillListApiConfig(getBillsClassName, getBillsMethodName, sendBillClassName, sendBillMethodName, NullifyBillClassName, NullifyBillMethodName) {
    this.getBillsClassName = getBillsClassName;
    this.getBillsMethodName = getBillsMethodName;
    this.sendBillClassName = sendBillClassName;
    this.sendBillMethodName = sendBillMethodName;
    this.NullifyBillClassName = NullifyBillClassName;
    this.NullifyBillMethodName = NullifyBillMethodName;
  }

  var initBillListApiConfig = function (isGYKS, BillType, ksGroup) {
    var apiConfig;
    switch (BillType) {
      case 'ly':
        if (isGYKS) {
          apiConfig = new BillListApiConfig('GyzxDrawBillManager', 'GetBillHeads', 'GyzxDrawBillManager', 'SendDrawBill', 'GyzxDrawBillManager', 'NullifyDrawBill');
        } else {
          apiConfig = new BillListApiConfig('MoveBillQueryManager', 'GetBills', 'DrawBillManager', 'SendDrawBill', 'DrawBillManager', 'NullifyDrawBill');
        }
        break;
      case 'zy':
        apiConfig = new BillListApiConfig('MoveBillQueryManager', 'GetBills', 'TransferBillManager', 'SendTransferBill', 'TransferBillManager', 'NullifyTransferBill');
        break;
      case 'jh':
        apiConfig = new BillListApiConfig('MoveBillQueryManager', 'GetBills', 'DrawBackBillManager', 'SendDrawBackBill', 'DrawBackBillManager', 'NullifyDrawBackBill');
        break;
      case 'dh':
        if (ksGroup) {
          apiConfig = new BillListApiConfig('PackTransBillQueryManager', 'QueryWithDeptGroup', 'PackageTransBillManager', 'SendTransBill', 'PackageTransBillManager', 'NullifyTransBill');
        } else {
          apiConfig = new BillListApiConfig('PackTransBillQueryManager', 'Query', 'PackageTransBillManager', 'SendTransBill', 'PackageTransBillManager', 'NullifyTransBill');
        }
        break;
      case 'jy':
        if (ksGroup) {
          apiConfig = new BillListApiConfig('PackTransBillQueryManager', 'QueryWithDeptGroup', 'PackageDrawBillManager', 'SendDrawBill', 'PackageDrawBillManager', 'NullifyDrawBill');
        } else {
          apiConfig = new BillListApiConfig('PackTransBillQueryManager', 'Query', 'PackageDrawBillManager', 'SendDrawBill', 'PackageDrawBillManager', 'NullifyDrawBill');
        }
        break;
      case 'qxxd':
        apiConfig = new BillListApiConfig('DisinfectBillManager', 'GetDisinfectBillHeads', 'DisinfectBillManager', 'SendDisinfectBill', 'DisinfectBillManager', 'NullifyDisinfectBill');
        break;
      case 'sq':
        apiConfig = new BillListApiConfig('SqhzdManager', 'GetSqhzd', 'SqhzdManager', 'SendBill', 'SqhzdManager', 'DelBill');
        break;
    }
    return apiConfig;
  };

  // 创建请求信息
  var buildNewBillRequestParam = function (isGYKS, isSend, BillStatus, BillType) {
    var className, method, sendMethod, getBillClassName = 'MoveBillQueryManager',
      getBillMethod = 'GetBill';
    var status = (BillStatus === 'new' ? (isSend ? 'fs' : 'lr') : 'lr');
    var info = (BillStatus === 'new' ? (isSend ? '发送成功' : '保存成功') : '修改成功');

    switch (BillType) {
      case 'ly':
        if (isGYKS) {
          className = 'GyzxDrawBillManager';
          method = BillStatus === 'new' ? 'InputDrawBill' : 'ModifyDrawBill';
          getBillClassName = 'GyzxDrawBillManager';
        } else {
          className = 'DrawBillManager';
          method = BillStatus === 'new' ? 'InputDrawBill' : 'ModifyDrawBill';
        }
        sendMethod = 'SendDrawBill';
        break;
      case 'zy':
        className = 'TransferBillManager';
        method = BillStatus === 'new' ? 'InputTransferBill' : 'ModifyTransferBill';
        sendMethod = 'SendTransferBill';
        break;
      case 'jh':
        className = 'DrawBackBillManager';
        method = BillStatus === 'new' ? 'InputDrawBackBill' : 'ModifyDrawBackBill';
        sendMethod = 'SendDrawBackBill';
        break;
      case 'dh':
        className = 'PackageTransBillManager';
        method = BillStatus === 'new' ? 'InputTransBill' : 'ModifyTransBill';
        sendMethod = 'SendTransBill';
        getBillClassName = 'PackTransBillQueryManager';
        getBillMethod = 'GetTransBill';
        break;
      case 'jy':
        className = 'PackageDrawBillManager';
        method = BillStatus === 'new' ? 'InputDrawBill' : 'ModifyDrawBill';
        sendMethod = 'SendDrawBill';
        getBillClassName = 'PackTransBillQueryManager';
        getBillMethod = 'GetTransBill';
        break;
      case 'qxxd':
        className = 'DisinfectBillManager';
        method = BillStatus === 'new' ? 'InputDisinfectBill' : 'ModifyDistinfectBill';
        sendMethod = 'SendDisinfectBill';
        getBillClassName = 'DisinfectBillManager';
        getBillMethod = 'GetDisinfectBill';
        break;
      case 'sq':
        className = 'SqhzdManager';
        method = BillStatus === 'new' ? 'SaveBill' : 'SaveBill';
        sendMethod = 'SendBill';
        getBillClassName = 'SqhzdManager';
        getBillMethod = 'GetSqhzd';
        break;
    }

    return {
      info: info,
      method: method,
      className: className,
      status: status,
      sendMethod: sendMethod,
      getBillMethod: getBillMethod,
      getBillClassName: getBillClassName
    };
  };

  return {
    initBillListApiConfig: initBillListApiConfig,
    buildNewBillRequestParam: buildNewBillRequestParam
  };
});